<?php
/* @var $this TransferController */
/* @var $dataProvider CActiveDataProvider */
Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl . "/global/js/pages/transferAudit.js"); 
$this->breadcrumbs=array(
	'部门调动',
	'收件箱'=>array('transfer/inbox'),
	'调动审核'=>array('transferAudit/index?id='.$data['transfer']->id),
);

?>
<span class="page_h3">调动审核</span>

<div class="detail_div">
<br />
	<div id="notice" style=" <?php if ($error != 0) { ?> display:block;<?php  } else {?> display:none; <?php } ?>">
    <? if ($error == 2) {
			echo '请选择新部门！';
		} else if($error == 3) {
			echo '请选择调动的元素！';
		} else if($error == 1) {
			echo '请填写调动说明！';
		}
	?>
    </div>
    <div class="form">
    	<form name="audit_form" id="audit_form" action="<?php echo Yii::app()->request->baseUrl.'/transferAudit/index/'; ?>" method="post">
        <table cellpadding="1" cellspacing="1" class="c_table">
         	
            <tr>
                <td width="100"  align="right"  class="td-blue">单 号：</td>
                <td> <?php echo $data['transfer']->id ?> </td>
            </tr>
            <tr>
                <td align="right"  class="td-blue">调动人员信息：</td>
                <td>
                <?php if ($formType == 1) { ?>
                <table class="c_table">
                	 <tr> <td class="td-blue">人员</td> <td class="td-blue">基本信息</td> <td width="300" class="td-blue">职级信息</td></tr>
                    <?php foreach($data['transfer']->user as $v)
						  { 
						  
						  //echo $v->id;
						  ?>
                      <tr> 
                        <td><?php echo $v->c_username ?></td> <td>工号：<?php echo $v->unique_id ?><br />邮箱：<?php echo $v->username ?><br />入职时间：<?php echo $v->entry_point ?></td>
                        <td>属性：<?php echo HrPositionAttribute::getInfoById($v->old_attr_id,'title'); ?><br />L：<?php echo HrPositionLevel::getInfoById($v->old_L,'name'); ?><br />M：<?php echo HrPositionLevel::getInfoById($v->old_M,'name'); ?></td>
                      </tr>
                      <tr>
                      	<td>职级是否变动：</td>
                        <td colspan="2">
                        <?php  if($v->new_attr_id || $v->new_L || $v->new_M) { 
							$display = 1;
						} else {
							$display = 0;
						}
						if($v->new_attr_id != 0 &&$v->new_L != 0) {
							//获取所有职位描述
							$positionLevelsL = HrPositionLevel::model()->findAllByAttributes(array('status' => 1),' Level like "L%" AND attr_id='.$v->new_attr_id);
							$positionLevelOptionL[0] = '请选择';
							foreach ($positionLevelsL as $value) {
								$positionLevelOptionL[$value['id']] = $value['name'];
							}
						} else {
							$positionLevelOptionL[0] = '请选择';
						}
						
						?>
                        <select name="change-<?php echo $v->id; ?>" class="user_level_change small_select" style="margin-left:8px;">
                        	<option value="0" <?php if ($display == 0) { ?>selected="selected" <?php  }?>>否</option>
                            <option value="1" <?php if ($display == 1) { ?>selected="selected" <?php  }?> >是</option>
                        </select>
                        <div id="new_user_info_<?php echo $v->id; ?>" <?php if ($display == 0) { ?>style="display:none;<?php  }?>">
                        	<table class="c_table_inner">
                            	<tr>
                                	<td>属性 ：</td>
                                    <td><?php echo CHtml::dropDownList('attr_id-'.$v->id , $v->new_attr_id ,$paOption,array('class'=>'user_attr mid_select')); ?> </td>
                                </tr>
                                <tr>
                                	<td>L：</td>
                                    <td><?php echo CHtml::dropDownList('attr_L_id-'.$v->id , $v->new_L ,$positionLevelOptionL,array('class'=>'mid_select')); ?> </td>
                                </tr>
                                <tr>
                                	<td>M：</td>
                                    <td><?php echo CHtml::dropDownList('attr_M_id-'.$v->id , $v->new_M ,$positionLevelOptionM,array('class'=>'mid_select')); ?> </td>
                                </tr>
                            </table>
                        </div>
                        </td>
                      </tr>
                    <?php }?>
                </table>
                
                <?php  } else if ($formType == 2) { ?>
                
                <table class="c_table">
                	 <tr> <td class="td-blue">人员</td> <td class="td-blue">基本信息</td> <td width="300" class="td-blue">职级信息</td></tr>
                    <?php foreach($data['transfer']->user as $v)
						  { 
						  ?>
                      <tr> 
                        <td><?php echo $v->c_username ?></td> <td>工号：<?php echo $v->unique_id ?><br />邮箱：<?php echo $v->username ?><br />入职时间：<?php echo $v->entry_point ?></td>
                        <td>属性：<?php echo HrPositionAttribute::getInfoById($v->old_attr_id,'title'); ?><br />L：<?php echo HrPositionLevel::getInfoById($v->old_L,'name'); ?><br />M：<?php echo HrPositionLevel::getInfoById($v->old_M,'name'); ?></td>
                      </tr>
                      <tr>
                      	<td>职级变动：</td>
                        <td colspan="2">
                        
                        <?php if($v->new_attr_id || $v->new_L || $v->new_M) { ?>
                        
                        <div id="new_user_info_<?php echo $v->id; ?>">
                        	<table class="c_table_inner">
                            	<tr>
                                	<td  width="70">属性 ：</td>
                                    <td><?php echo HrPositionAttribute::model()->getInfoById($v->new_attr_id,'title'); ?> </td>
                                </tr>
                                <tr>
                                	<td>L：</td>
                                    <td><?php echo HrPositionLevel::model()->getInfoById($v->new_L,'name') ?> </td>
                                </tr>
                                <tr>
                                	<td>M：</td>
                                    <td><?php echo HrPositionLevel::model()->getInfoById($v->new_M,'name') ?> </td>
                                </tr>
                            </table>
                        </div>
                        <?php } ?>
                        </td>
                      </tr>
                    <?php }?>
                </table>
                
				<?php } else { ?>
				
				<table class="c_table">
                	 <tr> <td class="td-blue">人员 </td> <td class="td-blue">基本信息</td> <td width="300" class="td-blue">职级信息</td></tr>
                    <?php foreach($data['transfer']->user as $v)
						  { ?>
                      <tr> 
                        <td><?php echo $v->c_username ?></td> <td>工号：<?php echo $v->unique_id ?><br />邮箱：<?php echo $v->username ?><br />入职时间：<?php echo $v->entry_point ?></td>
                        <td>属性：<?php echo HrPositionAttribute::getInfoById($v->old_attr_id,'title'); ?><br />L：<?php echo HrPositionLevel::getInfoById($v->old_L,'name'); ?><br />M：<?php echo HrPositionLevel::getInfoById($v->old_M,'name'); ?></td>
                      </tr>
                    <?php }?>
                </table>
				
				<?php }?>
                </td>
            </tr>
            <tr>
                <td  align="right" class="td-blue">说 明：</td>
                <td colspan="3"> <?php echo $data['transfer']->note;?> </td>
            </tr>
            <tr>
                <td  align="right" class="td-blue">原 部 门：</td>
                <td colspan="3" id=""> <?php echo $data['transfer']->from_department_name;?> </td>
            </tr>
            <tr>
                <td  align="right" class="td-blue">新 部 门：</td>
                <td colspan="3" id=""> <?php echo $data['transfer']->to_department_name;?> </td>
            </tr>
            <tr>
                <td  align="right" class="td-blue">发 起 人：</td>
                <td colspan="3" id=""><?php echo $data['transfer']->start_c_username;?></td>
            </tr>
            <tr>
                <td  align="right" class="td-blue">审核流程：</td>
                <td colspan="3" id=""> 
                <?php
				$hecUserModel = new HecUser;
				$count = count($data['transfer']->process);
				foreach($data['transfer']->process as $k => $v)
				{
					$m = $hecUserModel-> findByAttributes(array('unique_id' => $v->unique_id));
					echo $m->c_username;
					if($k < ($count-1))
						echo '<img src="'.Yii::app()->request->baseUrl.'/global/img/icons/arrow_right.gif" />';
				}
				?>
                </td>
            </tr>
            <tr>
                <td  align="right" class="td-blue">生效时间：</td>
                <td colspan="3"> 
                <?php echo date("Y-m-d",$data['transfer']->effective_time); ?>
                </td>
            </tr>
            <tr>
                <td  align="right" class="td-blue">当前审核人：</td>
                <td colspan="3" id=""> 
                <?php
				echo $data['transfer']->next_c_username;
				?>
                </td>
            </tr>
            <tr>
                <td valign="top"  align="right" class="td-blue">流程记录：</td>
                <td colspan="3" id=""> 
                <?php
                if(isset($data['transferIndex'])) {
					echo '<table class="c_table">';
					foreach($data['transferIndex'] as $v)
					{
						echo '<tr>';
						echo '<td width="50">'.$v['c_username'].'</td><td width="50"> '.$v['action_name'].'</td><td> '.$v['note'].'</td><td width="120"> '.$v['action_time'].'</td>';
						echo '<tr>';
					}
					echo '</table>';
				}
				?>
                </td>
            </tr>
            <tr>
                <td  align="right" class="td-blue">审 核：</td>
                <td  colspan="3" id=""> 
                <?php
				$flArray = array(0=>'--- 请选择 ---',1=>'通过' ,-1=>'驳回');
				echo CHtml::dropDownList('check' ,'0' ,$flArray ,array('class'=>'c_select'));
				?>
                </td>
            </tr>
            <tr>
                <td  align="right" class="td-blue">说 明：</td>
                <td colspan="3" id=""> 
                <textarea class="c_textarea" id="form_note" name="form_note"></textarea>
                </td>
            </tr>
            <tr>
                <td colspan="4" align="center">
                <input type="hidden" value="<?php echo Yii::app()->request->csrfToken; ?>" name="YII_CSRF_TOKEN"  />
                <input type="hidden" value="<?php echo $data['transfer']->id ?>" name="id"  />
                <input type="submit" id="form_submit" class="c_button" value=" 确 定 " />  <input type="button" class="c_button" onclick="javascript:history.go(-1);" value=" 返 回 " />
                </td>
            </tr>
        </table>
        </form>
    </div><!-- form -->
	<br />
</div>

